package com.app.mymusic.test.dagger2;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import android.widget.Toast;

import com.app.mymusic.R;

import java.lang.ref.WeakReference;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DaggerActivity extends AppCompatActivity implements UserContact.Iview {

    @BindView(R.id.tv1)
    TextView tv1;
    @Inject
    DaggerPresenter presenter;
    @Inject
    User user;

    private WeakReference actReference;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dagger);
        ButterKnife.bind(this);
        DaggerDaggerComponent.builder()
                .daggerModule(new DaggerModule(DaggerActivity.this))
                .build().inject(this);
    }

    @OnClick(R.id.tv1)
    public void onClick() {
        user.setName(tv1.getText().toString().trim());
        user.setAddress("郑州");
        user.setEmail("56225@qq.com");
        presenter.request(user);
    }

    public void showName(String name) {
        Toast.makeText(this, name, Toast.LENGTH_SHORT).show();
    }
    public void showSSSSS( ) {
        Toast.makeText(this, "SSSSSS", Toast.LENGTH_SHORT).show();
    }
    public void showEEEE( ) {
        Toast.makeText(this, "EEEEE", Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void showSucess() {
        Toast.makeText(this, "SSSSSS", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void showError() {
        Toast.makeText(this, "EEEEE", Toast.LENGTH_SHORT).show();
    }
}
